class Solution {
public:

    double pow(double x, long long n)
    {
        if (n == 0)  return 1;

        double tmp = pow(x, n / 2);
        return n % 2 == 0 ? tmp * tmp : tmp * tmp * x;
    }

    double myPow(double x, long long n) {
        double ret = pow(x, n);
        return n < 0 ? 1 / ret : ret;
    }
};